"""
数据模型定义
"""
from typing import Dict, List, Optional, Any, Union
from pydantic import BaseModel, Field

class Message(BaseModel):
    """消息模型"""
    role: str
    content: str
    tool_calls: Optional[List[Dict[str, Any]]] = None
    tool_call_id: Optional[str] = None

class QueryRequest(BaseModel):
    """查询请求模型"""
    query: str
    history: Optional[List[Message]] = Field(default_factory=list)
    conversation_id: Optional[str] = None

class QueryResponse(BaseModel):
    """查询响应模型"""
    success: bool
    data: Optional[Dict[str, Any]] = None
    error: Optional[str] = None
    conversation_id: Optional[str] = None

class ToolCall(BaseModel):
    """工具调用模型"""
    tool: str
    args: Dict[str, Any]
    result: Any
    error: Optional[str] = None

class ConversationContext(BaseModel):
    """对话上下文模型"""
    conversation_id: str
    messages: List[Message] = Field(default_factory=list)
    server_id: Optional[str] = None
    last_active: float = 0
    metadata: Dict[str, Any] = Field(default_factory=dict)